<template>
  <div>
        <h1>姓名：{{info.name}}</h1>
        <h2>年龄：{{info.age}}</h2>
        <h2>兴趣：{{info.interest}}</h2>
    </div>
</template>

<script>
  import axios from 'axios';
  export default {
    data(){
      return {
        name:'hello world'
      }
    },
    // asyncData(){   //过时
    //   return axios.get('https://api.myjson.com/bins/qa4tk').then(res => {
    //     console.log(res)
    //     return {info:res.data}
    //   })
    // }


    async asyncData(){
       let {data} = await axios.get('https://api.myjson.com/bins/qa4tk')
       console.log(data)
       return {info:data}
       error(params)//当请求错误时直接跳转到错误页面(放在返回值之后)
    }

  }
</script>

<style>
</style>
